import Home from "@/views/Home.vue";
import About from "@/views/About.vue";
import AboutFoo from "@/views/AboutFoo.vue";
import AboutBar from "@/views/AboutBar.vue";
import BazZoo from "@/views/BarZoo.vue";

import {createRouter , createWebHistory} from 'vue-router'

//1：定义路由
const routes = [
    {
        path: '/',
        name: 'Home',
        component: Home
    },
    {
        path: '/about',
        name: 'About',
        component: About,
        children: [
            {
                path: 'aboutfoo/:id',
                name: 'foo',
                component: AboutFoo,

                //可以控制权限
                //console.log(this.$route.meta.auth)
                meta:{auth:true}
            },
            {
                path: 'aboutbar',
                name: 'bar',
                components: {
                    default: AboutBar,
                    baz: BazZoo
                },

                //可以控制权限
                //console.log(this.$route.meta.auth)
                meta:{auth:false}
            }
        ]
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes
})

//2：导出
export default router;
